package wang.chunfan.springcloud.learning.feign.server.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import wang.chunfan.springcloud.learning.feign.server.feign.fallback.UserFeignFallback;
import wang.chunfan.springcloud.learning.feign.server.model.Result;
import wang.chunfan.springcloud.learning.feign.server.model.User;

import java.util.List;

/**
 * @version 1.0
 * @Author wangchunfan
 * @Date 2020/5/23 20:59
 **/
@FeignClient(value = "user-server", fallback = UserFeignFallback.class)
public interface UserFeign {
    @PostMapping("/user")
    Result insert(@RequestBody User user);

    @DeleteMapping("/user/{id}")
    Result delete(@PathVariable Long id);

    @PutMapping("/user")
    Result update(@RequestBody User user);

    @GetMapping("/user/{id}")
    Result<User> get(@PathVariable Long id);

    @GetMapping("/user/list")
    Result<List<User>> list(@RequestParam List<Long> ids);

    @GetMapping("/user/getByUsername/{username}")
    Result<List<User>> getByUsername(@PathVariable String username);
}
